import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:getx_scaffold_ohos/common/index.dart';
import 'package:tdesign_flutter/tdesign_flutter.dart';

import '../recommend/recommend_view.dart';
import 'home_logic.dart';

class HomePage extends StatefulWidget {
  const HomePage({super.key});

  @override
  State<HomePage> createState() => _HomePageState();
}

class _HomePageState extends State<HomePage>
    with AutomaticKeepAliveClientMixin {
  @override
  Widget build(BuildContext context) {
    super.build(context);
    final HomeLogic logic = Get.put(HomeLogic());

    return Scaffold(
      appBar: AppBar(
        title: TDTabBar(
          tabs: const [
            TDTab(text: '推荐'),
            TDTab(text: '广场'),
            TDTab(text: '问答'),
          ],
          controller: logic.tabController,
          backgroundColor: Colors.white,
          showIndicator: true,
          dividerHeight: 0,
          labelStyle: TextStyle(fontWeight: FontWeight.bold, fontSize: 18.sp),
          unselectedLabelStyle:
              TextStyle(fontWeight: FontWeight.normal, fontSize: 14.sp),
        ),
        centerTitle: true,
        elevation: 0,
      ),
      body: TDTabBarView(
        children: [
          RecommendPage(),
          Center(
            child: Text('广场'),
          ),
          Center(
            child: Text('问答'),
          ),
        ],
        controller: logic.tabController,
        isSlideSwitch: true,
      ),
    );
  }

  @override
  bool get wantKeepAlive => true;
}
